
-- --------------------------------------------------
-- Entity Designer DDL Script for SQL Server 2005, 2008, and Azure
-- --------------------------------------------------
-- Date Created: 05/23/2012 13:50:44
-- Generated from EDMX file: F:\tfs21\teamfrancetriple\Captain\FranceTriple.Dal\Model1.edmx
-- --------------------------------------------------

SET QUOTED_IDENTIFIER OFF;
GO
IF SCHEMA_ID(N'dbo') IS NULL EXECUTE(N'CREATE SCHEMA [dbo]');
GO

-- --------------------------------------------------
-- Dropping existing FOREIGN KEY constraints
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[FK_aspnet_RoleEntity1]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[aspnet_RolesForumSet] DROP CONSTRAINT [FK_aspnet_RoleEntity1];
GO
IF OBJECT_ID(N'[dbo].[FK_Bf3RankBf3PlayerProperty]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Bf3PlayerPropertySet] DROP CONSTRAINT [FK_Bf3RankBf3PlayerProperty];
GO
IF OBJECT_ID(N'[dbo].[FK_EventCategoryEvent]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[EventSet] DROP CONSTRAINT [FK_EventCategoryEvent];
GO
IF OBJECT_ID(N'[dbo].[FK_ForumAnnonceForumTopic_ForumAnnonce]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ForumAnnonceForumTopic] DROP CONSTRAINT [FK_ForumAnnonceForumTopic_ForumAnnonce];
GO
IF OBJECT_ID(N'[dbo].[FK_ForumAnnonceForumTopic_ForumTopic]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ForumAnnonceForumTopic] DROP CONSTRAINT [FK_ForumAnnonceForumTopic_ForumTopic];
GO
IF OBJECT_ID(N'[dbo].[FK_ForumCategoryForumTopic]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ForumTopicSet] DROP CONSTRAINT [FK_ForumCategoryForumTopic];
GO
IF OBJECT_ID(N'[dbo].[FK_ForumEntity1]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[aspnet_RolesForumSet] DROP CONSTRAINT [FK_ForumEntity1];
GO
IF OBJECT_ID(N'[dbo].[FK_ForumForumCategory]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ForumCategorySet] DROP CONSTRAINT [FK_ForumForumCategory];
GO
IF OBJECT_ID(N'[dbo].[FK_ForumPostForumPostRead]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ForumPostReadSet] DROP CONSTRAINT [FK_ForumPostForumPostRead];
GO
IF OBJECT_ID(N'[dbo].[FK_ForumTopicForumPost]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ForumPostSet] DROP CONSTRAINT [FK_ForumTopicForumPost];
GO
IF OBJECT_ID(N'[dbo].[FK_ForumTopicPoll]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[PollSet] DROP CONSTRAINT [FK_ForumTopicPoll];
GO
IF OBJECT_ID(N'[dbo].[FK_FriendlyTeamFriendlyTeamGuildMaster]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[FriendlyTeamGuildMasterSet] DROP CONSTRAINT [FK_FriendlyTeamFriendlyTeamGuildMaster];
GO
IF OBJECT_ID(N'[dbo].[FK_FriendlyTeamFriendlyTeamMember]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[FriendlyTeamMemberSet] DROP CONSTRAINT [FK_FriendlyTeamFriendlyTeamMember];
GO
IF OBJECT_ID(N'[dbo].[FK_FriendlyTeamGameServer]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[GameServerSet] DROP CONSTRAINT [FK_FriendlyTeamGameServer];
GO
IF OBJECT_ID(N'[dbo].[FK_GameGameServer]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[GameServerSet] DROP CONSTRAINT [FK_GameGameServer];
GO
IF OBJECT_ID(N'[dbo].[FK_GamePlayerOnGame]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[PlayerOnGameSet] DROP CONSTRAINT [FK_GamePlayerOnGame];
GO
IF OBJECT_ID(N'[dbo].[FK_PlayerOnGameBf3PlayerProperty]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Bf3PlayerPropertySet] DROP CONSTRAINT [FK_PlayerOnGameBf3PlayerProperty];
GO
IF OBJECT_ID(N'[dbo].[FK_PollAnswerPollUser]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[PollUserSet] DROP CONSTRAINT [FK_PollAnswerPollUser];
GO
IF OBJECT_ID(N'[dbo].[FK_PollPollAnswer]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[PollAnswerSet] DROP CONSTRAINT [FK_PollPollAnswer];
GO
IF OBJECT_ID(N'[dbo].[FK_PrivateMessageBoxPrivateMessageRead]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[PrivateMessageReadSet] DROP CONSTRAINT [FK_PrivateMessageBoxPrivateMessageRead];
GO
IF OBJECT_ID(N'[dbo].[FK_PublisherGame]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[GameSet] DROP CONSTRAINT [FK_PublisherGame];
GO

-- --------------------------------------------------
-- Dropping existing tables
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[ApplicationSettingSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ApplicationSettingSet];
GO
IF OBJECT_ID(N'[dbo].[aspnet_RolesForumSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[aspnet_RolesForumSet];
GO
IF OBJECT_ID(N'[dbo].[Bf3PlayerPropertySet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Bf3PlayerPropertySet];
GO
IF OBJECT_ID(N'[dbo].[Bf3RankSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Bf3RankSet];
GO
IF OBJECT_ID(N'[dbo].[EventCategorySet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[EventCategorySet];
GO
IF OBJECT_ID(N'[dbo].[EventSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[EventSet];
GO
IF OBJECT_ID(N'[dbo].[ForumAnnonceForumTopic]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ForumAnnonceForumTopic];
GO
IF OBJECT_ID(N'[dbo].[ForumAnnonceSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ForumAnnonceSet];
GO
IF OBJECT_ID(N'[dbo].[ForumCategorySet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ForumCategorySet];
GO
IF OBJECT_ID(N'[dbo].[ForumPostReadSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ForumPostReadSet];
GO
IF OBJECT_ID(N'[dbo].[ForumPostSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ForumPostSet];
GO
IF OBJECT_ID(N'[dbo].[ForumSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ForumSet];
GO
IF OBJECT_ID(N'[dbo].[ForumSmilieSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ForumSmilieSet];
GO
IF OBJECT_ID(N'[dbo].[ForumTopicSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ForumTopicSet];
GO
IF OBJECT_ID(N'[dbo].[FriendlyTeamGuildMasterSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[FriendlyTeamGuildMasterSet];
GO
IF OBJECT_ID(N'[dbo].[FriendlyTeamMemberSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[FriendlyTeamMemberSet];
GO
IF OBJECT_ID(N'[dbo].[FriendlyTeamSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[FriendlyTeamSet];
GO
IF OBJECT_ID(N'[dbo].[GameServerSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[GameServerSet];
GO
IF OBJECT_ID(N'[dbo].[GameSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[GameSet];
GO
IF OBJECT_ID(N'[dbo].[PlayerOnGameSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[PlayerOnGameSet];
GO
IF OBJECT_ID(N'[dbo].[PollAnswerSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[PollAnswerSet];
GO
IF OBJECT_ID(N'[dbo].[PollSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[PollSet];
GO
IF OBJECT_ID(N'[dbo].[PollUserSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[PollUserSet];
GO
IF OBJECT_ID(N'[dbo].[PrivateMessageBoxSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[PrivateMessageBoxSet];
GO
IF OBJECT_ID(N'[dbo].[PrivateMessageReadSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[PrivateMessageReadSet];
GO
IF OBJECT_ID(N'[dbo].[PublisherSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[PublisherSet];
GO
IF OBJECT_ID(N'[dbo].[ShoutBoxSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ShoutBoxSet];
GO
IF OBJECT_ID(N'[dbo].[SmilieSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[SmilieSet];
GO

-- --------------------------------------------------
-- Creating all tables
-- --------------------------------------------------

-- Creating table 'ForumCategorySet'
CREATE TABLE [dbo].[ForumCategorySet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [LabelForumCategory] nvarchar(128)  NOT NULL,
    [DescriptionForumCategory] nvarchar(max)  NULL,
    [OrderForumCategory] int  NOT NULL,
    [NumberOfTopic] int  NOT NULL,
    [NumberOfMessage] int  NOT NULL,
    [LastPostId] int  NULL,
    [LastPostCreationDate] datetime  NULL,
    [LastPostAuthor] nvarchar(128)  NULL,
    [LastPostTopicId] int  NULL,
    [Forum_Id] int  NOT NULL
);
GO

-- Creating table 'ForumPostSet'
CREATE TABLE [dbo].[ForumPostSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [PostMessage_Label] nvarchar(128)  NULL,
    [PostMessage_Message] nvarchar(max)  NOT NULL,
    [PostMessage_CreationDate] datetime  NOT NULL,
    [PostMessage_Author] nvarchar(128)  NOT NULL,
    [PostMessage_AuthorAdressIp] nvarchar(15)  NOT NULL,
    [ForumTopic_Id] int  NOT NULL
);
GO

-- Creating table 'ForumTopicSet'
CREATE TABLE [dbo].[ForumTopicSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [LabelForumTopic] nvarchar(128)  NOT NULL,
    [AuthorForumTopic] nvarchar(128)  NOT NULL,
    [NumberHasBeenSeenForumTopic] int  NOT NULL,
    [OrderForumTopic] int  NOT NULL,
    [IsUnlocked] bit  NOT NULL,
    [CreationDateForumTopic] datetime  NOT NULL,
    [ForumCategory_Id] int  NOT NULL
);
GO

-- Creating table 'ShoutBoxSet'
CREATE TABLE [dbo].[ShoutBoxSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [UserNameAuthorShoutBox] nvarchar(256)  NOT NULL,
    [MessageShoutBox] nvarchar(1024)  NOT NULL,
    [CreationDateShoutBox] datetime  NOT NULL
);
GO

-- Creating table 'ForumSet'
CREATE TABLE [dbo].[ForumSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [LabelForum] nvarchar(128)  NOT NULL,
    [OrderForum] int  NOT NULL
);
GO

-- Creating table 'EventSet'
CREATE TABLE [dbo].[EventSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [AuthorEvent] nvarchar(256)  NOT NULL,
    [TitleEvent] nvarchar(128)  NOT NULL,
    [DateStartEvent] datetime  NOT NULL,
    [DateEndEvent] datetime  NOT NULL,
    [AllDayEvent] bit  NOT NULL,
    [DescriptionEvent] nvarchar(max)  NULL,
    [EventCategory_Id] int  NOT NULL
);
GO

-- Creating table 'EventCategorySet'
CREATE TABLE [dbo].[EventCategorySet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [LabelEventCategory] nvarchar(128)  NOT NULL,
    [ColorEventCategory] nchar(6)  NOT NULL,
    [BackColorEventCategory] nchar(6)  NOT NULL
);
GO

-- Creating table 'PollSet'
CREATE TABLE [dbo].[PollSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [LabelPoll] nvarchar(128)  NOT NULL,
    [DescriptionPoll] nvarchar(max)  NULL,
    [CreationDatePoll] datetime  NOT NULL,
    [OrderPoll] int  NOT NULL,
    [DurationInDays] int  NOT NULL,
    [ForumTopic_Id] int  NOT NULL
);
GO

-- Creating table 'PollAnswerSet'
CREATE TABLE [dbo].[PollAnswerSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [LabelPollAnwser] nvarchar(128)  NOT NULL,
    [NumberVotePollAnswer] int  NOT NULL,
    [Poll_Id] int  NOT NULL
);
GO

-- Creating table 'SmilieSet'
CREATE TABLE [dbo].[SmilieSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [CodeSmilie] nvarchar(16)  NOT NULL,
    [ImageFileName] nvarchar(64)  NOT NULL
);
GO

-- Creating table 'ForumSmilieSet'
CREATE TABLE [dbo].[ForumSmilieSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [CodeSmilie] nvarchar(16)  NOT NULL,
    [ImageFileName] nvarchar(64)  NOT NULL,
    [IsUsedForComposed] bit  NOT NULL
);
GO

-- Creating table 'ForumAnnonceSet'
CREATE TABLE [dbo].[ForumAnnonceSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [UpperTextForumAnnonce] nvarchar(128)  NOT NULL,
    [BottomForumAnnonce] nvarchar(128)  NOT NULL,
    [ShowOnForumCategoryAnnonce] bit  NOT NULL,
    [ShowOnTopicForumAnnonce] bit  NOT NULL,
    [ShowOnPostForumAnnonce] bit  NOT NULL,
    [DateBeginForumAnnonce] datetime  NOT NULL,
    [DateEndForumAnnonce] datetime  NULL,
    [OrderForumAnnonce] int  NOT NULL
);
GO

-- Creating table 'PrivateMessageBoxSet'
CREATE TABLE [dbo].[PrivateMessageBoxSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [AuthorPrivateMessage] nvarchar(128)  NOT NULL,
    [ToPrivateMessage] uniqueidentifier  NOT NULL,
    [MessageBody_Label] nvarchar(128)  NULL,
    [MessageBody_Message] nvarchar(max)  NOT NULL,
    [MessageBody_CreationDate] datetime  NOT NULL,
    [MessageBody_Author] nvarchar(128)  NOT NULL,
    [MessageBody_AuthorAdressIp] nvarchar(15)  NOT NULL
);
GO

-- Creating table 'ForumPostReadSet'
CREATE TABLE [dbo].[ForumPostReadSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [UserId] uniqueidentifier  NOT NULL,
    [ForumPost_Id] int  NOT NULL
);
GO

-- Creating table 'PrivateMessageReadSet'
CREATE TABLE [dbo].[PrivateMessageReadSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [UserId] uniqueidentifier  NOT NULL,
    [PrivateMessageBox_Id] int  NOT NULL
);
GO

-- Creating table 'PollUserSet'
CREATE TABLE [dbo].[PollUserSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [UserId] uniqueidentifier  NOT NULL,
    [UserIp] nvarchar(15)  NOT NULL,
    [PollAnswer_Id] int  NOT NULL
);
GO

-- Creating table 'aspnet_RolesForumSet'
CREATE TABLE [dbo].[aspnet_RolesForumSet] (
    [Role_Id] uniqueidentifier  NOT NULL,
    [Forum_Id] int  NOT NULL,
    [RightLevel] smallint  NOT NULL
);
GO

-- Creating table 'ApplicationSettingSet'
CREATE TABLE [dbo].[ApplicationSettingSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [Name] nvarchar(128)  NOT NULL,
    [Value] nvarchar(128)  NOT NULL
);
GO

-- Creating table 'FriendlyTeamSet'
CREATE TABLE [dbo].[FriendlyTeamSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [WebsiteFriendlyTeam] nvarchar(128)  NULL,
    [NameFriendlyTeam] nvarchar(128)  NOT NULL,
    [TeamspeakIpFriendlyTeam] nvarchar(128)  NULL,
    [TeamSpeakPasswordFriendlyTeam] nvarchar(32)  NULL,
    [BannerImageUrlFriendlyTeam] nvarchar(512)  NULL,
    [DescriptionFriendlyTeam] nvarchar(max)  NULL,
    [TagFriendlyTeam] nvarchar(16)  NULL,
    [IsPublicVisibleFriendlyTeam] bit  NOT NULL,
    [Bf3PlatoonUrlFriendlyTeam] nvarchar(512)  NULL
);
GO

-- Creating table 'FriendlyTeamMemberSet'
CREATE TABLE [dbo].[FriendlyTeamMemberSet] (
    [TeamId] int  NOT NULL,
    [UserId] uniqueidentifier  NOT NULL
);
GO

-- Creating table 'FriendlyTeamGuildMasterSet'
CREATE TABLE [dbo].[FriendlyTeamGuildMasterSet] (
    [TeamId] int  NOT NULL,
    [UserId] uniqueidentifier  NOT NULL
);
GO

-- Creating table 'GameSet'
CREATE TABLE [dbo].[GameSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [NameGame] nvarchar(max)  NOT NULL,
    [NicknameGame] nvarchar(max)  NOT NULL,
    [OfficialWebSiteGame] nvarchar(max)  NOT NULL,
    [ImageUrlGame] nvarchar(max)  NOT NULL,
    [LogoUrlGame] nvarchar(max)  NOT NULL,
    [DescriptionGame] nvarchar(max)  NOT NULL,
    [Publisher_Id] int  NOT NULL
);
GO

-- Creating table 'GameServerSet'
CREATE TABLE [dbo].[GameServerSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [AddressGameServer] nvarchar(max)  NOT NULL,
    [PasswordGameServer] nvarchar(max)  NOT NULL,
    [Game_Id] int  NOT NULL,
    [FriendlyTeam_Id] int  NOT NULL
);
GO

-- Creating table 'PlayerOnGameSet'
CREATE TABLE [dbo].[PlayerOnGameSet] (
    [GameId] int  NOT NULL,
    [UserId] uniqueidentifier  NOT NULL,
    [PlayerNickName] nvarchar(max)  NOT NULL,
    [Game_Id] int  NOT NULL
);
GO

-- Creating table 'PublisherSet'
CREATE TABLE [dbo].[PublisherSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [NamePublisher] nvarchar(max)  NOT NULL,
    [OfficialWebSitePublisher] nvarchar(max)  NOT NULL
);
GO

-- Creating table 'Bf3PlayerPropertySet'
CREATE TABLE [dbo].[Bf3PlayerPropertySet] (
    [GameId] int  NOT NULL,
    [UserId] uniqueidentifier  NOT NULL,
    [TimePlayedToBecomeColonel] nvarchar(max)  NOT NULL,
    [DisplayOrderHallOfFamousPlayer] nvarchar(max)  NOT NULL,
    [BattlelogUrlProfile] nvarchar(max)  NOT NULL,
    [Bf3RankSet_Id] int  NOT NULL
);
GO

-- Creating table 'Bf3RankSet'
CREATE TABLE [dbo].[Bf3RankSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [RankNumber] int  NOT NULL,
    [RankImageUrl] nvarchar(512)  NOT NULL
);
GO

-- Creating table 'Bf3RankSmiliesSet'
CREATE TABLE [dbo].[Bf3RankSmiliesSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [Rank] smallint  NOT NULL,
    [ImageUrl] nvarchar(64)  NOT NULL
);
GO

-- Creating table 'ForumAnnonceForumTopic'
CREATE TABLE [dbo].[ForumAnnonceForumTopic] (
    [ForumAnnonce_Id] int  NOT NULL,
    [ForumTopic_Id] int  NOT NULL
);
GO

-- --------------------------------------------------
-- Creating all PRIMARY KEY constraints
-- --------------------------------------------------

-- Creating primary key on [Id] in table 'ForumCategorySet'
ALTER TABLE [dbo].[ForumCategorySet]
ADD CONSTRAINT [PK_ForumCategorySet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'ForumPostSet'
ALTER TABLE [dbo].[ForumPostSet]
ADD CONSTRAINT [PK_ForumPostSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'ForumTopicSet'
ALTER TABLE [dbo].[ForumTopicSet]
ADD CONSTRAINT [PK_ForumTopicSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'ShoutBoxSet'
ALTER TABLE [dbo].[ShoutBoxSet]
ADD CONSTRAINT [PK_ShoutBoxSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'ForumSet'
ALTER TABLE [dbo].[ForumSet]
ADD CONSTRAINT [PK_ForumSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'EventSet'
ALTER TABLE [dbo].[EventSet]
ADD CONSTRAINT [PK_EventSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'EventCategorySet'
ALTER TABLE [dbo].[EventCategorySet]
ADD CONSTRAINT [PK_EventCategorySet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'PollSet'
ALTER TABLE [dbo].[PollSet]
ADD CONSTRAINT [PK_PollSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'PollAnswerSet'
ALTER TABLE [dbo].[PollAnswerSet]
ADD CONSTRAINT [PK_PollAnswerSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'SmilieSet'
ALTER TABLE [dbo].[SmilieSet]
ADD CONSTRAINT [PK_SmilieSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'ForumSmilieSet'
ALTER TABLE [dbo].[ForumSmilieSet]
ADD CONSTRAINT [PK_ForumSmilieSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'ForumAnnonceSet'
ALTER TABLE [dbo].[ForumAnnonceSet]
ADD CONSTRAINT [PK_ForumAnnonceSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'PrivateMessageBoxSet'
ALTER TABLE [dbo].[PrivateMessageBoxSet]
ADD CONSTRAINT [PK_PrivateMessageBoxSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'ForumPostReadSet'
ALTER TABLE [dbo].[ForumPostReadSet]
ADD CONSTRAINT [PK_ForumPostReadSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'PrivateMessageReadSet'
ALTER TABLE [dbo].[PrivateMessageReadSet]
ADD CONSTRAINT [PK_PrivateMessageReadSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'PollUserSet'
ALTER TABLE [dbo].[PollUserSet]
ADD CONSTRAINT [PK_PollUserSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Role_Id], [Forum_Id] in table 'aspnet_RolesForumSet'
ALTER TABLE [dbo].[aspnet_RolesForumSet]
ADD CONSTRAINT [PK_aspnet_RolesForumSet]
    PRIMARY KEY CLUSTERED ([Role_Id], [Forum_Id] ASC);
GO

-- Creating primary key on [Id] in table 'ApplicationSettingSet'
ALTER TABLE [dbo].[ApplicationSettingSet]
ADD CONSTRAINT [PK_ApplicationSettingSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'FriendlyTeamSet'
ALTER TABLE [dbo].[FriendlyTeamSet]
ADD CONSTRAINT [PK_FriendlyTeamSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [TeamId], [UserId] in table 'FriendlyTeamMemberSet'
ALTER TABLE [dbo].[FriendlyTeamMemberSet]
ADD CONSTRAINT [PK_FriendlyTeamMemberSet]
    PRIMARY KEY CLUSTERED ([TeamId], [UserId] ASC);
GO

-- Creating primary key on [TeamId], [UserId] in table 'FriendlyTeamGuildMasterSet'
ALTER TABLE [dbo].[FriendlyTeamGuildMasterSet]
ADD CONSTRAINT [PK_FriendlyTeamGuildMasterSet]
    PRIMARY KEY CLUSTERED ([TeamId], [UserId] ASC);
GO

-- Creating primary key on [Id] in table 'GameSet'
ALTER TABLE [dbo].[GameSet]
ADD CONSTRAINT [PK_GameSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'GameServerSet'
ALTER TABLE [dbo].[GameServerSet]
ADD CONSTRAINT [PK_GameServerSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [GameId], [UserId] in table 'PlayerOnGameSet'
ALTER TABLE [dbo].[PlayerOnGameSet]
ADD CONSTRAINT [PK_PlayerOnGameSet]
    PRIMARY KEY CLUSTERED ([GameId], [UserId] ASC);
GO

-- Creating primary key on [Id] in table 'PublisherSet'
ALTER TABLE [dbo].[PublisherSet]
ADD CONSTRAINT [PK_PublisherSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [GameId], [UserId] in table 'Bf3PlayerPropertySet'
ALTER TABLE [dbo].[Bf3PlayerPropertySet]
ADD CONSTRAINT [PK_Bf3PlayerPropertySet]
    PRIMARY KEY CLUSTERED ([GameId], [UserId] ASC);
GO

-- Creating primary key on [Id] in table 'Bf3RankSet'
ALTER TABLE [dbo].[Bf3RankSet]
ADD CONSTRAINT [PK_Bf3RankSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'Bf3RankSmiliesSet'
ALTER TABLE [dbo].[Bf3RankSmiliesSet]
ADD CONSTRAINT [PK_Bf3RankSmiliesSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [ForumAnnonce_Id], [ForumTopic_Id] in table 'ForumAnnonceForumTopic'
ALTER TABLE [dbo].[ForumAnnonceForumTopic]
ADD CONSTRAINT [PK_ForumAnnonceForumTopic]
    PRIMARY KEY NONCLUSTERED ([ForumAnnonce_Id], [ForumTopic_Id] ASC);
GO

-- --------------------------------------------------
-- Creating all FOREIGN KEY constraints
-- --------------------------------------------------

-- Creating foreign key on [ForumCategory_Id] in table 'ForumTopicSet'
ALTER TABLE [dbo].[ForumTopicSet]
ADD CONSTRAINT [FK_ForumCategoryForumTopic]
    FOREIGN KEY ([ForumCategory_Id])
    REFERENCES [dbo].[ForumCategorySet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_ForumCategoryForumTopic'
CREATE INDEX [IX_FK_ForumCategoryForumTopic]
ON [dbo].[ForumTopicSet]
    ([ForumCategory_Id]);
GO

-- Creating foreign key on [ForumTopic_Id] in table 'ForumPostSet'
ALTER TABLE [dbo].[ForumPostSet]
ADD CONSTRAINT [FK_ForumTopicForumPost]
    FOREIGN KEY ([ForumTopic_Id])
    REFERENCES [dbo].[ForumTopicSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_ForumTopicForumPost'
CREATE INDEX [IX_FK_ForumTopicForumPost]
ON [dbo].[ForumPostSet]
    ([ForumTopic_Id]);
GO

-- Creating foreign key on [Forum_Id] in table 'ForumCategorySet'
ALTER TABLE [dbo].[ForumCategorySet]
ADD CONSTRAINT [FK_ForumForumCategory]
    FOREIGN KEY ([Forum_Id])
    REFERENCES [dbo].[ForumSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_ForumForumCategory'
CREATE INDEX [IX_FK_ForumForumCategory]
ON [dbo].[ForumCategorySet]
    ([Forum_Id]);
GO

-- Creating foreign key on [Poll_Id] in table 'PollAnswerSet'
ALTER TABLE [dbo].[PollAnswerSet]
ADD CONSTRAINT [FK_PollPollAnswer]
    FOREIGN KEY ([Poll_Id])
    REFERENCES [dbo].[PollSet]
        ([Id])
    ON DELETE CASCADE ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_PollPollAnswer'
CREATE INDEX [IX_FK_PollPollAnswer]
ON [dbo].[PollAnswerSet]
    ([Poll_Id]);
GO

-- Creating foreign key on [ForumTopic_Id] in table 'PollSet'
ALTER TABLE [dbo].[PollSet]
ADD CONSTRAINT [FK_ForumTopicPoll]
    FOREIGN KEY ([ForumTopic_Id])
    REFERENCES [dbo].[ForumTopicSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_ForumTopicPoll'
CREATE INDEX [IX_FK_ForumTopicPoll]
ON [dbo].[PollSet]
    ([ForumTopic_Id]);
GO

-- Creating foreign key on [EventCategory_Id] in table 'EventSet'
ALTER TABLE [dbo].[EventSet]
ADD CONSTRAINT [FK_EventCategoryEvent]
    FOREIGN KEY ([EventCategory_Id])
    REFERENCES [dbo].[EventCategorySet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_EventCategoryEvent'
CREATE INDEX [IX_FK_EventCategoryEvent]
ON [dbo].[EventSet]
    ([EventCategory_Id]);
GO

-- Creating foreign key on [ForumPost_Id] in table 'ForumPostReadSet'
ALTER TABLE [dbo].[ForumPostReadSet]
ADD CONSTRAINT [FK_ForumPostForumPostRead]
    FOREIGN KEY ([ForumPost_Id])
    REFERENCES [dbo].[ForumPostSet]
        ([Id])
    ON DELETE CASCADE ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_ForumPostForumPostRead'
CREATE INDEX [IX_FK_ForumPostForumPostRead]
ON [dbo].[ForumPostReadSet]
    ([ForumPost_Id]);
GO

-- Creating foreign key on [PrivateMessageBox_Id] in table 'PrivateMessageReadSet'
ALTER TABLE [dbo].[PrivateMessageReadSet]
ADD CONSTRAINT [FK_PrivateMessageBoxPrivateMessageRead]
    FOREIGN KEY ([PrivateMessageBox_Id])
    REFERENCES [dbo].[PrivateMessageBoxSet]
        ([Id])
    ON DELETE CASCADE ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_PrivateMessageBoxPrivateMessageRead'
CREATE INDEX [IX_FK_PrivateMessageBoxPrivateMessageRead]
ON [dbo].[PrivateMessageReadSet]
    ([PrivateMessageBox_Id]);
GO

-- Creating foreign key on [ForumAnnonce_Id] in table 'ForumAnnonceForumTopic'
ALTER TABLE [dbo].[ForumAnnonceForumTopic]
ADD CONSTRAINT [FK_ForumAnnonceForumTopic_ForumAnnonce]
    FOREIGN KEY ([ForumAnnonce_Id])
    REFERENCES [dbo].[ForumAnnonceSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [ForumTopic_Id] in table 'ForumAnnonceForumTopic'
ALTER TABLE [dbo].[ForumAnnonceForumTopic]
ADD CONSTRAINT [FK_ForumAnnonceForumTopic_ForumTopic]
    FOREIGN KEY ([ForumTopic_Id])
    REFERENCES [dbo].[ForumTopicSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_ForumAnnonceForumTopic_ForumTopic'
CREATE INDEX [IX_FK_ForumAnnonceForumTopic_ForumTopic]
ON [dbo].[ForumAnnonceForumTopic]
    ([ForumTopic_Id]);
GO

-- Creating foreign key on [PollAnswer_Id] in table 'PollUserSet'
ALTER TABLE [dbo].[PollUserSet]
ADD CONSTRAINT [FK_PollAnswerPollUser]
    FOREIGN KEY ([PollAnswer_Id])
    REFERENCES [dbo].[PollAnswerSet]
        ([Id])
    ON DELETE CASCADE ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_PollAnswerPollUser'
CREATE INDEX [IX_FK_PollAnswerPollUser]
ON [dbo].[PollUserSet]
    ([PollAnswer_Id]);
GO

-- Creating foreign key on [Role_Id] in table 'aspnet_RolesForumSet'
ALTER TABLE [dbo].[aspnet_RolesForumSet]
ADD CONSTRAINT [FK_aspnet_RoleEntity1]
    FOREIGN KEY ([Role_Id])
    REFERENCES [dbo].[aspnet_Roles]
        ([RoleId])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Forum_Id] in table 'aspnet_RolesForumSet'
ALTER TABLE [dbo].[aspnet_RolesForumSet]
ADD CONSTRAINT [FK_ForumEntity1]
    FOREIGN KEY ([Forum_Id])
    REFERENCES [dbo].[ForumSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_ForumEntity1'
CREATE INDEX [IX_FK_ForumEntity1]
ON [dbo].[aspnet_RolesForumSet]
    ([Forum_Id]);
GO

-- Creating foreign key on [TeamId] in table 'FriendlyTeamMemberSet'
ALTER TABLE [dbo].[FriendlyTeamMemberSet]
ADD CONSTRAINT [FK_FriendlyTeamFriendlyTeamMember]
    FOREIGN KEY ([TeamId])
    REFERENCES [dbo].[FriendlyTeamSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [TeamId] in table 'FriendlyTeamGuildMasterSet'
ALTER TABLE [dbo].[FriendlyTeamGuildMasterSet]
ADD CONSTRAINT [FK_FriendlyTeamFriendlyTeamGuildMaster]
    FOREIGN KEY ([TeamId])
    REFERENCES [dbo].[FriendlyTeamSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Game_Id] in table 'GameServerSet'
ALTER TABLE [dbo].[GameServerSet]
ADD CONSTRAINT [FK_GameGameServer]
    FOREIGN KEY ([Game_Id])
    REFERENCES [dbo].[GameSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_GameGameServer'
CREATE INDEX [IX_FK_GameGameServer]
ON [dbo].[GameServerSet]
    ([Game_Id]);
GO

-- Creating foreign key on [FriendlyTeam_Id] in table 'GameServerSet'
ALTER TABLE [dbo].[GameServerSet]
ADD CONSTRAINT [FK_FriendlyTeamGameServer]
    FOREIGN KEY ([FriendlyTeam_Id])
    REFERENCES [dbo].[FriendlyTeamSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_FriendlyTeamGameServer'
CREATE INDEX [IX_FK_FriendlyTeamGameServer]
ON [dbo].[GameServerSet]
    ([FriendlyTeam_Id]);
GO

-- Creating foreign key on [Game_Id] in table 'PlayerOnGameSet'
ALTER TABLE [dbo].[PlayerOnGameSet]
ADD CONSTRAINT [FK_GamePlayerOnGame]
    FOREIGN KEY ([Game_Id])
    REFERENCES [dbo].[GameSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_GamePlayerOnGame'
CREATE INDEX [IX_FK_GamePlayerOnGame]
ON [dbo].[PlayerOnGameSet]
    ([Game_Id]);
GO

-- Creating foreign key on [Publisher_Id] in table 'GameSet'
ALTER TABLE [dbo].[GameSet]
ADD CONSTRAINT [FK_PublisherGame]
    FOREIGN KEY ([Publisher_Id])
    REFERENCES [dbo].[PublisherSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_PublisherGame'
CREATE INDEX [IX_FK_PublisherGame]
ON [dbo].[GameSet]
    ([Publisher_Id]);
GO

-- Creating foreign key on [GameId], [UserId] in table 'Bf3PlayerPropertySet'
ALTER TABLE [dbo].[Bf3PlayerPropertySet]
ADD CONSTRAINT [FK_PlayerOnGameBf3PlayerProperty]
    FOREIGN KEY ([GameId], [UserId])
    REFERENCES [dbo].[PlayerOnGameSet]
        ([GameId], [UserId])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Bf3RankSet_Id] in table 'Bf3PlayerPropertySet'
ALTER TABLE [dbo].[Bf3PlayerPropertySet]
ADD CONSTRAINT [FK_Bf3RankBf3PlayerProperty]
    FOREIGN KEY ([Bf3RankSet_Id])
    REFERENCES [dbo].[Bf3RankSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_Bf3RankBf3PlayerProperty'
CREATE INDEX [IX_FK_Bf3RankBf3PlayerProperty]
ON [dbo].[Bf3PlayerPropertySet]
    ([Bf3RankSet_Id]);
GO

-- --------------------------------------------------
-- Script has ended
-- --------------------------------------------------